# -*- coding: utf-8 -*-
# @File     : decorators.py
# @Author   : bingjia
# @Time     : 2020/7/30 9:29
# @Desc     : 装饰器

# -*- coding: utf-8 -*-
# @File     : decorators.py
# @Author   : bingjia
# @Time     : 2020/4/13 18:18
# @Desc     : 装饰器


def detail_route(methods=['get'], **kwargs):
    """
    Used to mark a method on a ViewSet that should be routed for detail requests.
    """
    def decorator(func):
        func.bind_to_methods = methods
        func.detail = True
        func.permission_classes = kwargs.get('permission_classes', [])
        func.kwargs = kwargs
        return func
    return decorator


def list_route(methods=['get'], **kwargs):
    """
    Used to mark a method on a ViewSet that should be routed for list requests.
    """
    def decorator(func):
        func.bind_to_methods = methods
        func.detail = False
        func.permission_classes = kwargs.get('permission_classes', [])
        func.kwargs = kwargs
        return func
    return decorator


